#pragma once
#include "Task_Base/Task_Base.h"
#include "OpenSLES/iaudiodata.h"
#include  <map>
struct AVFormatContext;
class MediaImagehandler;
class StreamAbstract;
class AudioAbstract;
class DemuxerTask : public Task_Base,public IAudioData
{
public:
	DemuxerTask();
	virtual ~DemuxerTask();
public:
    bool open(const std::string &url,AudioAbstract *event,MediaImagehandler *handler);
    void close();
public:
    virtual int GetAudio(char * buf,int len);
public:
    virtual void stream_close_message();
    virtual void stream_data_message(const char *data,int size);
    virtual void stream_stop_message();
public:
	int recv_buffer(unsigned char *buf, int buf_size);
protected:
	virtual int svc();//
private:
    StreamAbstract * findAudio();
    StreamAbstract * findVideo();
    void StatusUpdates();
    void CloseStreamTask();
private:
    AVFormatContext    *pFormatCtx;
    CCriticalSection    *oManSection;
    std::map<int,StreamAbstract*> m_oManStream;
private:
    int                 bExit;
    std::string         m_buffer;
    AudioAbstract       * m_oAudioAbstract;
    MediaImagehandler   *m_oMediaImagehandler;
private:
};
